//
//  AppDelegate.m
//  Demo3
//
//  Created by cora1n on 14-8-21.
//  Copyright (c) 2014年 devwu. All rights reserved.
//

#import "AppDelegate.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
    UITextField * tf1 = [[UITextField alloc]initWithFrame:CGRectMake(40, 100, 120, 40)];
    //设置文本框的边框
//    [tf1 setBorderStyle:UITextBorderStyleRoundedRect];
    //设置文本的颜色
//    [tf1 setTextColor:[UIColor greenColor]];
    //设置占位符
    [tf1 setPlaceholder:@"我是占位符"];
    //通过KVC访问私有成员 _placeHolderLabel.textColor
    [tf1 setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];
    //设置文本框的文字(当文本框内包含文字时,占位符不会显示)
    [tf1 setText:@"我是文字"];
    //设置文本框的背景图片
    //  1.将图片加载到内存中,PNG格式的图片可以省略后缀,名称包含@2x的图片可以自动适配屏幕
    UIImage * bgImage = [UIImage imageNamed:@"1"];
    //  2.将图片设置为文本框背景
    [tf1 setBackground:bgImage];
    [tf1 setTextAlignment:NSTextAlignmentCenter];
    [self.window addSubview:tf1];
    
    //textField 的代理
    [tf1 setDelegate:self];
    
    
    UISlider * slider = [[UISlider alloc]initWithFrame:CGRectMake(30, 200, 200, 30)];
    [slider setValue:0.7];
    [self.window addSubview:slider];
    [slider addTarget:self action:@selector(doSlider:) forControlEvents:UIControlEventValueChanged];
    
    
    _progress = [[UIProgressView alloc]initWithFrame:CGRectMake(30, 250, 200, 30)];
    
    [_progress setProgress:0.3];
    [self.window addSubview:_progress];
    
    //警告框
//    UIAlertView * alert1 = [[UIAlertView alloc]initWithTitle:@"TTTitle" message:@"MMMMeasege" delegate:self cancelButtonTitle:@"Cancle" otherButtonTitles:@"Other1", nil];
//    [alert1 setAlertViewStyle:UIAlertViewStyleDefault];
//    [alert1 show];
//    
//    //弹出框
//    UIActionSheet * sheet1 = [[UIActionSheet alloc]initWithTitle:@"TTTitle" delegate:nil cancelButtonTitle:@"cancel" destructiveButtonTitle:@"destructive" otherButtonTitles:@"other", nil];
//    [sheet1 showInView:self.window];
//    
    
    //日期
    UIDatePicker * datePicker = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 0, 320, 100)];
    [self.window addSubview:datePicker];
    
    
    return YES;
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSLog(@"索引值为%d",buttonIndex);
}
-(void)doSlider:(UISlider*)slider
{
    NSLog(@"%f",slider.value);
    _progress.progress=slider.value;
}
//文本开始编辑是调用该方法
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
    NSLog(@"开始文本编辑");
}
-(void)textFieldDidEndEditing:(UITextField *)textField
{
    NSLog(@"结束文本编辑");
}
//指定返回键是否可点击
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    //取消文本框的焦点
    [textField resignFirstResponder];
    return YES;
}
@end
